<?php
class Library_Model_AuthorMapper extends Library_Model_DomainObjectAbstract
{
	private static $_instance = null;
	public function searchById($id){
		
	}
	public function searchByBookId($id){
		$db = $this->getDb();
		
		$selectAuthors = $db->select()
		->from('author')
		->join('book_author_relations'.'authors.author_id = book_author_relations.author_id')
		->where('book_id = ?', $id);
		$authors = $db->fetchAll($selectAuthors);
		
		$authorsArray = array();
		//Zend_Registry::get('logger')->info($authors);
		foreach($authors as $author){
			$authorObj = new Library_Model_Author();
			$authorObj->setId($author['author_id'])
					->setNameFirst($author['nameFirst'])
					->setNameLast($author['nameLast']);
			$authorsArray = $authorObj;
		}
		return $authorsArray;
	}
	protected function _populate($data){
		
	}
	protected function _insert(Library_Model_DomainObjectAbstract $obj){
		
	}
	protected function _update(Library_Model_DomainObjectAbstract $obj){
		
	}
	/* 
	@return Library_Model_AuthorMapper
	 */
	public static function getInstance(){
		if(is_null(self::$_instance)){
			$c = __CLASS__;
			self::$_instance = new $c;
		}
		return self::$_instance;
	}
}